package com.ziq.zcamp.util;

public class CharUtils {

    private static final int CHINESE_START_CHARACTER = '\u4e00';
    private static final int CHINESE_END_CHARACTER = '\u9fa5';

    private static final int NUM_START_CHARACTER = '0';
    private static final int NUM_END_CHARACTER = '9';

    private static final int ENGLISH_LOWER_START_CHARACTER = 'a';
    private static final int ENGLISH_LOWER_END_CHARACTER = 'z';

    private static final int ENGLISH_CAPITALIZE_START_CHARACTER = 'A';
    private static final int ENGLISH_CAPITALIZE_END_CHARACTER = 'Z';

    /**
     * 判断是否是字母
     * @param c char
     * @return 是否是字母
     */
    public static boolean isLetter(int c){
        return (c >= ENGLISH_LOWER_START_CHARACTER && c <= ENGLISH_LOWER_END_CHARACTER) ||
                (c >= ENGLISH_CAPITALIZE_START_CHARACTER && c <= ENGLISH_CAPITALIZE_END_CHARACTER);
    }

    /**
     * 判断是否是中文
     * @param c char
     * @return 是否是中文
     */
    public static boolean isChinese(int c){
        return c >= CHINESE_START_CHARACTER && c <= CHINESE_END_CHARACTER;
    }

    /**
     * 判断是否是数字
     * @param c char
     * @return 是否是数字
     */
    public static boolean isNum(int c){
        return c >= NUM_START_CHARACTER && c <= NUM_END_CHARACTER;
    }

    /**
     * 是否是emoji表情
     * @param codePoint Character.codePointAt(handleCharSequence, i) 获取的字符编码
     * @return 是否是表情
     */
    public static boolean isEmojiCharacter(int codePoint) {
        return (0x0080<=codePoint&&codePoint<=0x02AF)||
                (0x0300<=codePoint&&codePoint<=0x03FF)||
                (0x0600<=codePoint&&codePoint<=0x06FF)||
                (0x0C00<=codePoint&&codePoint<=0x0C7F)||
                (0x1DC0<=codePoint&&codePoint<=0x1DFF)||
                (0x1E00<=codePoint&&codePoint<=0x1EFF)||
                (0x2000<=codePoint&&codePoint<=0x209F)||
                (0x20D0<=codePoint&&codePoint<=0x214F)||
                (0x2190<=codePoint&&codePoint<=0x23FF)||
                (0x2460<=codePoint&&codePoint<=0x25FF)||
                (0x2600<=codePoint&&codePoint<=0x27EF)||
                (0x2900<=codePoint&&codePoint<=0x29FF)||
                (0x2B00<=codePoint&&codePoint<=0x2BFF)||
                (0x2C60<=codePoint&&codePoint<=0x2C7F)||
                (0x2E00<=codePoint&&codePoint<=0x2E7F)||
                (0xA490<=codePoint&&codePoint<=0xA4CF)||
                (0xE000<=codePoint&&codePoint<=0xF8FF)||
                (0xFE00<=codePoint&&codePoint<=0xFE0F)||
                (0xFE30<=codePoint&&codePoint<=0xFE4F)||
                (0x1F000<=codePoint&&codePoint<=0x1F02F)||
                (0x1F0A0<=codePoint&&codePoint<=0x1F0FF)||
                (0x1F100<=codePoint&&codePoint<=0x1F64F)||
                (0x1F680<=codePoint&&codePoint<=0x1F6FF)||
                (0x1F910<=codePoint&&codePoint<=0x1F96B)||
                (0x1F980<=codePoint&&codePoint<=0x1F9E0);
    }
}
